<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>后台管理</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="icon" href="javascript:;">
  <link rel="stylesheet" href="../../resource/layui/css/layui.css"  media="all">
  <link rel="stylesheet" href="../../resource/myResource/css/no_read_item.css">
  <link rel="stylesheet" href="../../resource/myResource/css/personal/personal_detail.css">
</head>
<style>
</style>
<body>
    <div class="layui-collapse">
            <div class="layui-colla-item">
                <h2 class="layui-colla-title">
                    <li class="layui-nav-item" style="width:75px">
                        <a href="javascropt:;">添加管理员</span></a>
                    </li>
                </h2>
                <div class="layui-colla-content  layui-show" style="padding-top:0px; height: 481x;">
                    <!-- <iframe id="page" src="personal_detail.html" frameborder="0" id="demoAdmin" style="width: 100%; height: 99%;"></iframe>            -->
                    <form class="layui-form" action="" style="margin-top:30px;width: 75%;">
                        <div class="layui-form-item">
                            <label class="layui-form-label">姓名:</label>
                            <div class="layui-input-block">
                                <input id="name" type="text" name="name" placeholder="请输入真实姓名" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">账号:</label>
                            <div class="layui-input-block">
                                <input id="identity" type="text" name="identity" placeholder="请输入账号" autocomplete="off" class="layui-input" >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">密码:</label>
                            <div class="layui-input-block">
                                <input type="password" name="password" placeholder="初始密码：666666" autocomplete="off" class="layui-input" disabled style="border:0px;">
                            </div>
                        </div>
                        <div class="layui-form-item">
                                <label class="layui-form-label">区域:</label>
                                <div class="layui-input-block">
                                    <select id="areas" name="interest" lay-filter="areas">
                                    <option value="" selected=""></option>
                                    <!-- <option value="0">南区</option>
                                    <option value="1">北区</option> -->
                                    </select>
                                </div>
                            </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">权限:</label>
                            <div class="layui-input-block">
                                <select id = "powers" name="interest" lay-filter="powers">
                                <option value="" selected=""></option>
                                <!-- <option value="0">管理员</option>
                                <option value="1">临时管理员</option> -->
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item" style="margin-left:89%;">
                            <!-- <label class="layui-form-label">密码:</label> -->
                            <!-- <div class="layui-input-block">
                                <input type="password" name="password" placeholder="默认密码666666" autocomplete="off" class="layui-input" disabled>
                            </div> -->
                            <div style="margin-top:50px;margin-bottom: 25px">
                                <button type="button" class="layui-btn layui-btn-normal "style="margin-left:25px; margin-top:60px" onclick="submitBtn()">提交</button>
                            </div>
                        </div>
                       
            
                    </form>
                </div>
            </div>
        </div>

    
    <script src="../../resource/jquery/dist/jquery.js"></script>
    <script src="../../resource/layui/layui.js" charset="utf-8"></script>
    <script src="../../resource/myResource/js/base.js"></script>
    <script src="../..//resource/myResource/js/repaorjs/repair_no_read_item.js"></script>
    <script>
    function submitBtn(){
        var data = {};
        var area = $("#areas option:selected").attr('value');
        var power = $("#powers option:selected").attr('value');
        data.addUser = getId();
        data.area = area;
        data.power =power;
        data.name = $("#name").val();
        data.identity = $("#identity").val();
        console.info(data);
        console.info(JSON.stringify(data));
        $.ajax({
            url:head+"/manager/addManager",
            dataType:"JSON",
            data:JSON.stringify(data),
            contentType:"application/json;charset=UTF-8",
            type:"POST",
            success:function(redata){
                if(redata.code == 0){
                    setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
                    window.location.reload();//页面刷新
                    },1500);
                    if(redata.code == 0){
                        layer.msg("添加成功", {
                        time: 1500, //20s后自动关闭
                        //btn: ['明白了', '知道了', '哦']
                        });
                        return ;
                    }
                }else{
                    layer.msg(redata.msg, {
                        time: 1500, //20s后自动关闭
                        //btn: ['明白了', '知道了', '哦']
                        });
                        return ;
                }
                
            }
        });
    }
    </script>
    <script type="text/javascript">
    $(function(){
        var oid = getId();
        $.ajax({
            url:head+"/area/getArea",
            dataType:"json",
            type:"GET",
            success:function(redata){
                var data = redata.data;
                $.each(data,function(i,data){
                    $("#areas").append('<option value="'+data.id+'">'+data.areaName+'</option>');
                });
                layui.use(['table','form'],function(){
                    var form = layui.form;            
                    form.render('select');
                });
            }
        });

        $.ajax({
            url:head+"/power/getPower?id="+oid,
            dataType:"json",
            type:"GET",
            success:function(redata){
                var data = redata.data;
                $.each(data,function(i,data){
                    $("#powers").append('<option value="'+data.id+'">'+data.powerName+'</option>');
                });
                layui.use(['table','form'],function(){
                    var form = layui.form;
                    form.render('select');
                });

            }
        });

    })
      

        layui.use(['form', 'layedit', 'laydate'], function(){});
        //获得id渲染页面
        // alert(GetQueryString("id"));

        // 调用方法： 
        // alert(GetQueryString("id"));
        
       
    </script>
    
    <!-- <script src="../../resource/myResource/js/repaorjs/repair_history.js" charset="utf-8">    </script> -->
    
</body> 
</html>